package com.gitee.theskyzero.data.db.jdbc;

import com.gitee.theskyzero.data.db.Test;
import com.sun.istack.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/data/db/jdbc")
public class JdbcRestController {

    @Autowired
    JdbcTemplate jdbcTemplate;

    @GetMapping("/{id")
    public Test findById(@NotNull @PathVariable Long id) {
        return jdbcTemplate.queryForObject("select * from test where id=?", Test.class, id);
    }
}
